package com.xiaoxu.privatechat.entity.home;

import com.xiaoxu.privatechat.annotion.ValidateEntity;
import com.xiaoxu.privatechat.entity.common.Account;
import com.xiaoxu.privatechat.entity.common.BaseEntity;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

/**
 * @author xiaoxu
 * @description 前台好友请求实体类
 * @date 2023/2/13
 */
@Entity
@Table(name = "pc_friend_request")
@EntityListeners(AuditingEntityListener.class)
public class FriendRequest extends BaseEntity {
    private static final long serialVersionUID = 1L;
    /**
     * 待处理
     */
    public static final int FRIEND_REQUEST_STATUS_WAITING = 0;
    /**
     * 已同意
     */
    public static final int FRIEND_REQUEST_STATUS_AGREE = 1;
    /**
     * 已拒绝
     */
    public static final int FRIEND_REQUEST_STATUS_REFUSE = -1;
    /**
     * 已过期
     */
    public static final int FRIEND_REQUEST_STATUS_EXPIRED = 2;
    /**
     * 请求发出者
     */
    @ManyToOne
    @JoinColumn(name = "sender_account_id")
    private Account sender;
    /**
     * 请求接受者
     */
    @ManyToOne
    @JoinColumn(name = "reciever_account_id")
    private Account reciever;
    /**
     * 默认待处理请求
     */
    @ValidateEntity()
    @Column(name = "status", length = 1)
    private int status = FRIEND_REQUEST_STATUS_WAITING;

    /**
     * 备注
     */
    @ValidateEntity()
    @Column(name = "remark", length = 32)
    private String remark;


    public Account getSender() {
        return sender;
    }


    public void setSender(Account sender) {
        this.sender = sender;
    }


    public Account getReciever() {
        return reciever;
    }


    public void setReciever(Account reciever) {
        this.reciever = reciever;
    }


    public int getStatus() {
        return status;
    }


    public void setStatus(int status) {
        this.status = status;
    }


    public String getRemark() {
        return remark;
    }


    public void setRemark(String remark) {
        this.remark = remark;
    }


    @Override
    public String toString() {
        return "FriendRequest [sender=" + sender + ", reciever=" + reciever
                + ", status=" + status + ", remark=" + remark + "]";
    }


}
